<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>行为日志</el-breadcrumb-item>
      <el-breadcrumb-item>日志列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card shadow="always" :body-style="{ padding: '20px' }">
      <el-table :data="logList" style="width: 100%" border stripe>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="title" label="操作模块" ></el-table-column>
        <el-table-column prop="method" label="请求方式" ></el-table-column>
        <el-table-column prop="operName" label="操作人员"></el-table-column>
        <el-table-column prop="operIp" label="操作IP"></el-table-column>
        <el-table-column prop="operUrl" label="操作的url"></el-table-column>
      </el-table>
    </el-card>
  </div>
</template>   
<script>
export default {
  data(){
    return {
      queryInfo:{
        query:'',
        pagenum:1,
        pagesize:10
      },
      logList:[],
      total:0
    }
  },
  created(){
    this.getLogsList()
  },
  methods:{
    getLogsList:async function(){
      const {data:res}=await this.$http.get(`sys/findMyOperLog`)
      if(res.data.status!==200){
        return this.$message.error("获取失败")
      }
      this.$message.success("获取日志列表成功")
      this.logList=res.meta
      console.log(res.meta)
      this.total=res.meta.length
    },
    // 获取最新的pagesize
    handleSizeChange:function(newsize){
      this.queryInfo.pagesize=newsize
      this.getLogsList()
    },
    handleCurrentChange:function(newPage){
      this.queryInfo.pagenum=newPage
      this.getLogsList()
    },
    removeById:async function(id){
      // 确认对话框
      const confirmResult=await this.$confirm("此操作将永久删除,是否继续?",'删除商品',{
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).catch(err=>err)
      if(confirmResult!=='confirm'){
        return this.$message.info('已取消')
      }
      const {data:res}=await this.$http.delete(`goods/${id}`)
      console.log(res)
      if(res.meta.status!==200){
        return this.$message.error("删除失败")
      }
      this.$message.success("删除成功")
      this.getLogsList()
    },
    goAdd:function(){
      this.$router.push('goods/add')
    }
  }
}
</script>   
<style lang="less">

</style>
